package com.uls.web.controller.questionnaire;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uls.common.annotation.Log;
import com.uls.common.core.controller.BaseController;
import com.uls.common.core.domain.AjaxResult;
import com.uls.common.enums.BusinessType;
import com.uls.questionnaire.domain.ZxhQuestion;
import com.uls.questionnaire.service.IZxhQuestionService;
import com.uls.common.utils.poi.ExcelUtil;
import com.uls.common.core.page.TableDataInfo;

/**
 * 问题信息Controller
 * 
 * @author zxh
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/questionnaire/question")
public class ZxhQuestionController extends BaseController
{
    @Autowired
    private IZxhQuestionService zxhQuestionService;

    /**
     * 查询问题信息列表
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxhQuestion zxhQuestion)
    {
        startPage();
        List<ZxhQuestion> list = zxhQuestionService.selectZxhQuestionList(zxhQuestion);
        return getDataTable(list);
    }

    /**
     * 导出问题信息列表
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:export')")
    @Log(title = "问题信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxhQuestion zxhQuestion)
    {
        List<ZxhQuestion> list = zxhQuestionService.selectZxhQuestionList(zxhQuestion);
        ExcelUtil<ZxhQuestion> util = new ExcelUtil<ZxhQuestion>(ZxhQuestion.class);
        util.exportExcel(response, list, "问题信息数据");
    }

    /**
     * 获取问题信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:query')")
    @GetMapping(value = "/{questionId}")
    public AjaxResult getInfo(@PathVariable("questionId") Long questionId)
    {
        return success(zxhQuestionService.selectZxhQuestionByQuestionId(questionId));
    }

    /**
     * 新增问题信息
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:add')")
    @Log(title = "问题信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxhQuestion zxhQuestion)
    {
        return toAjax(zxhQuestionService.insertZxhQuestion(zxhQuestion));
    }

    /**
     * 修改问题信息
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:edit')")
    @Log(title = "问题信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxhQuestion zxhQuestion)
    {
        return toAjax(zxhQuestionService.updateZxhQuestion(zxhQuestion));
    }

    /**
     * 删除问题信息
     */
    @PreAuthorize("@ss.hasPermi('questionnaire:question:remove')")
    @Log(title = "问题信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{questionIds}")
    public AjaxResult remove(@PathVariable Long[] questionIds)
    {
        return toAjax(zxhQuestionService.deleteZxhQuestionByQuestionIds(questionIds));
    }
}
